//
//  UIbarButtonItem+Extensions.swift
//  新浪微博
//
//  Created by yaozhen on 2017/11/29.
//  Copyright © 2017年 ZYZ. All rights reserved.
//

import UIKit
extension UIBarButtonItem {
    // convenience 遍历构造函数
    //isBackButton
    convenience init(title:String, fontSize: CGFloat = 16,target: AnyObject?,action:Selector, isBack:Bool = false){
        let cusBtn:UIButton = UIButton.cz_textButton(title, fontSize:fontSize, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        cusBtn.addTarget(target, action:action, for: .touchUpInside)
        
        if isBack {
            let image = "navigationbar_back_withtext"
            
            cusBtn.setImage(UIImage.init(named: image), for: UIControlState.init(rawValue: 0))
            cusBtn.setImage(UIImage.init(named: image + "_highlighted"), for: .highlighted)
            cusBtn.sizeToFit()
        }
        //self.init 实例化 uibarButtonItem
        self.init(customView:cusBtn)
    }
}
